<template>
  <div class="card-register">
    <el-card class="box-card">
    
      <el-form
        ref="ruleFormRef"
        :model="ruleForm"
        status-icon
        label-width="120px"
        class="demo-ruleForm"
      >
        <el-form-item label="账号" prop="account">
          <el-input
            v-model="ruleForm.account"
            type="text"
            autocomplete="off"
            :disabled="!flag"
          />
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input
            v-model="ruleForm.password"
            type="password"
            autocomplete="off"
          />
        </el-form-item>
        <el-form-item label="名称" prop="name">
          <el-input v-model.number="ruleForm.name" />
        </el-form-item>
        <el-form-item label="电话" prop="tel">
          <el-input v-model.number="ruleForm.tel" />
        </el-form-item>
        <el-form-item label="角色" prop="role">
          <el-input v-model.number="ruleForm.role" />
        </el-form-item>

        <el-form-item>
          <!-- :disabled="flag" -->
          <el-button type="primary" @click="submitForm" 
            >提交</el-button
          >
          <el-button type="primary" @click="checkAccount" :disabled="!flag"
            >检测账号</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref } from "vue";
import type { IRegister } from "@/type/type";
import { AddusersAPI, detectionUsers } from "@/API/User";
// import { ElMessage } from "element-plus";

let flag = true;

const ruleForm = reactive<IRegister>({
  account: "",
  password: "",
  name: "",
  tel: "",
  role: "",
});

//提交
const submitForm = () => {
  AddusersAPI({ ...ruleForm }).then((res) => {
    console.log(res);
    //弹出res信息
    // ElMessage(res.data.data.msg);
  });
};

//检测账号
// const checkAccount = () => {
//   detectionUsers(
//     {account:account.value}
//   ).then((res)=>{
//     console.log(res);
    
//   })
// };
</script>

<style scoped>
.card-register {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #cce8cf;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.box-card {
  width: 480px;
}
</style>
